package com.infra.micro.oss.fallback;

import com.infra.common.resp.PageEx;
import com.infra.common.resp.Response;
import com.infra.micro.oss.api.OssFileInfoApi;
import com.infra.micro.oss.model.req.QueryFileInfoReq;
import com.infra.micro.oss.model.vo.FileInfoVO;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class OssFileInfoApiFallback implements FallbackFactory<OssFileInfoApi> {
    @Override
    public OssFileInfoApi create(Throwable cause) {
        return new OssFileInfoApi() {
            @Override
            public Response<FileInfoVO> queryByFileId(Long fileId) {
                return Response.error("服务异常[" + cause.getMessage() + "]，请联系相关服务负责人");
            }

            @Override
            public Response<List<FileInfoVO>> queryByFileIds(List<Long> fileIds) {
                return Response.error("服务异常[" + cause.getMessage() + "]，请联系相关服务负责人");
            }

            @Override
            public Response<PageEx<FileInfoVO, QueryFileInfoReq>> queryByPage(QueryFileInfoReq req) {
                return Response.error("服务异常[" + cause.getMessage() + "]，请联系相关服务负责人");
            }
        };
    }
}
